import logging
import redis


class Config(object):
    # 默认日志等级
    LOG_LEVEL = logging.DEBUG
    # 数据库配置
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/information'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # redis配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"
    # 指定sessio保存到redis
    SESSION_TYPE = 'redis'
    # 让 cookie 中的 session_id 被加密签名处理
    SESSION_USE_SIGNER = True
    # 使用 redis 的实例
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = 86400  # session 的有效期，单位是秒


class DevelopmentConfig(Config):
    # DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductConfig(Config):
    """生产模式下的配置"""
    LOG_LEVEL = logging.ERROR


config = {
    'develop': DevelopmentConfig,
    'product': ProductConfig
}